package com.qcs.sleep;

import android.content.Intent;
import android.graphics.Typeface;
import android.widget.TextView;

import com.jqing.lib.BaseActivity;
import com.jqing.lib.tools.DatetimeTools;
import com.qcs.sleep.call.CallTools;
import com.qcs.sleep.call.TimeWatcher;
import com.qcs.sleep.warn.ICallService;

/**
 * Created by chshqiang on 15-7-22.
 * 首页
 */
public class SplashActivity extends BaseActivity {

    private TextView tipTime;
    private TimeWatcher callWatcher;

    @Override
    protected void setContentView() {
        setContentView(R.layout.splash_lay);
    }

    protected void initializeData() {
        callWatcher = new TimeWatcher() {
            @Override
            public void update(Long time) {
                tipTime.setText(DatetimeTools.getTime4Millis(System.currentTimeMillis(), "HH:mm:ss"));
            }
        };
    }

    @Override
    protected void initializeView() {
        tipTime = (TextView) findViewById(R.id.tipTime);
    }

    @Override
    protected void setup() {
        tipTime.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/_roboto_thin.ttf"));

        CallTools.addWatcher(callWatcher);

        startService(new Intent(SplashActivity.this, ICallService.class));
    }

    @Override
    protected void onDestroy() {
        CallTools.removeWatcher(callWatcher);

        super.onDestroy();
    }

}
